﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using SoucreGame.GLO;

namespace SoucreGame.GUI
{
    class guiManHinhNhacNen
    {
        
        Texture2D guiManHinhNen; // hinh anh lam nen
        Texture2D guiNhacNen;
        Texture2D cmdNutBat;
        Texture2D cmdNutTat;

        Dictionary<string, Rectangle> dsToaDoGiaoDien;
        ContentManager content;
        GameTime gameTime;
        SpriteBatch spriteBatch;

        public guiManHinhNhacNen(ContentManager _content, GameTime _gameTime, SpriteBatch _spritBatch)
        {
            content = _content;
            gameTime = _gameTime;
            spriteBatch = _spritBatch;

            if (content != null)
            {
                guiManHinhNen = content.Load<Texture2D>("GUII\\guiManHinhNen");
                guiNhacNen = content.Load<Texture2D>("GUII\\guiManHinhNhacNen");
                cmdNutBat = content.Load<Texture2D>("GUII\\cmdNutBat");
                cmdNutTat = content.Load<Texture2D>("GUII\\cmdNutTat");

                dsToaDoGiaoDien = content.Load<Dictionary<string, Rectangle>>("GUII\\guiViTri");
            }
        }

        public void Update(GameTime gameTime)
        {
            CGlobalvariable.trangthaitruoc = CGlobalvariable.trangthaihientai;
            CGlobalvariable.trangthaihientai = Mouse.GetState();
            if (CGlobalvariable.trangthaihientai.LeftButton == ButtonState.Pressed && CGlobalvariable.trangthaitruoc.LeftButton == ButtonState.Released)
            {
                if (dsToaDoGiaoDien["cmdNutBat"].Contains(new Point(CGlobalvariable.trangthaihientai.X, CGlobalvariable.trangthaihientai.Y)))
                {

                    CGlobalvariable.Chuyengiaodien = true;
                    CGlobalvariable.Giaodiendangchon = GUIEnum.guiCaiDat;
                }

                else if (dsToaDoGiaoDien["cmdNutTat"].Contains(new Point(CGlobalvariable.trangthaihientai.X, CGlobalvariable.trangthaihientai.Y)))
                {
                    CGlobalvariable.Chuyengiaodien = true;
                    CGlobalvariable.Giaodiendangchon = GUIEnum.guiCaiDat;
                }
            }
        }

        public void Draw(GameTime gameTime)
        {
            this.spriteBatch.Draw(guiManHinhNen, Vector2.Zero, Color.White);
            this.spriteBatch.Draw(guiNhacNen, new Vector2(dsToaDoGiaoDien["guiManHinhNhacNen"].X, dsToaDoGiaoDien["guiManHinhNhacNen"].Y), Color.White);
            this.spriteBatch.Draw(cmdNutBat, new Vector2(dsToaDoGiaoDien["cmdNutBat"].X, dsToaDoGiaoDien["cmdNutBat"].Y), Color.White);
            this.spriteBatch.Draw(cmdNutTat, new Vector2(dsToaDoGiaoDien["cmdNutTat"].X, dsToaDoGiaoDien["cmdNutTat"].Y), Color.White);
        }
    }
}
